//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _UTIL_H
#define _UTIL_H
//
//file is included in global.h
//
template<class T> T qrand_interval(const T& p_min,const T& p_max)
{
   return p_min+(p_max-p_min)*(static_cast<double>(qrand())/(RAND_MAX-1));
}
//
inline QDataStream& operator<<(QDataStream& p_stream,const osg::Vec3& p_vec)
{
   return p_stream<<p_vec.x()<<p_vec.y()<<p_vec.z();
}
inline QDataStream& operator>>(QDataStream& p_stream,osg::Vec3& p_vec)
{
   return p_stream>>p_vec.x()>>p_vec.y()>>p_vec.z();
}
inline QDataStream& operator<<(QDataStream& p_stream,const osg::Vec4& p_vec)
{
   return p_stream<<p_vec.x()<<p_vec.y()<<p_vec.z()<<p_vec.w();
}
inline QDataStream& operator>>(QDataStream& p_stream,osg::Vec4& p_vec)
{
   return p_stream>>p_vec.x()>>p_vec.y()>>p_vec.z()>>p_vec.w();
}
//
#define DISABLE_ADDRESSOF(Class) private: \
   Class *operator&(); \
   const Class *operator&() const;
//
#endif